<%@ Page Language="C#" MasterPageFile="~/MasterDefault.master" AutoEventWireup="True"
    Inherits="TeamTime.TasksForm" Title="Team Time - Tasks" StylesheetTheme="Default"
    CodeBehind="TasksForm.aspx.cs" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="TaskFormControl.ascx" TagName="TaskFormControl" TagPrefix="uc1" %>
<%@ Register Src="DescriptionPopupControl.ascx" TagName="DescriptionPopupControl" TagPrefix="uc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true">
        <Services>
            <asp:ServiceReference Path="AutoComplete.asmx" />
        </Services>
    </asp:ScriptManager>
    <clib:UpdatePanelExtender runat="server" ID="UpdatePanelExtender1" UpdateMode="Conditional">
        <ContentTemplate>
            <h3>
                Tasks &nbsp; &nbsp;<asp:Button runat="server" ID="btnAddNew" Text="Add New" OnClick="btnAddNew_Click"
                    CausesValidation="False" />
            </h3>
            <asp:Button runat="server" ID="btnAddDummy" Text="Add New" Visible="true" Style="display: none;" />
            <clib:ModalPopupPanel runat="server" ID="popUp1" TargetControlID="btnAddDummy" Width="650px"
                Title="Task" Height="">
                <uc1:TaskFormControl ID="TaskFormControl1" runat="server" OnSaveClicked="TaskFormControl1_SaveClicked"
                    OnLoadDupClicked="TaskFormControl1_LoadDupClicked" />
            </clib:ModalPopupPanel>
            <asp:Button runat="server" ID="btnAddDummy2" Text="Add New" Visible="true" Style="display: none;" />
            <clib:ModalPopupPanel runat="server" ID="popUp2" TargetControlID="btnAddDummy2" Width="350px"
                Title="Description" Height="">
                <uc2:DescriptionPopupControl ID="DescriptionPopupControl1" runat="server" />
            </clib:ModalPopupPanel>
            <asp:Panel ID="pnlSearch" runat="server" DefaultButton="btnSearch">
                <table id="tblHead" cellspacing="0" cellpadding="1" border="0" runat="server" width="75%">
                    <tr>
                        <td>
                            Search for&nbsp;
                        </td>
                        <td>
                            <asp:TextBox ID="txtSearchFor" runat="server" MaxLength="100" Width="200px"></asp:TextBox>
                            <asp:CheckBox ID="chkSearchDetails" runat="server" Visible="true" />
                            Search in details&nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Allocated To
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlStaffMemberIDAllocatedTo" runat="server" Enabled="false">
                            </asp:DropDownList>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Company
                        </td>
                        <td>
                            <asp:TextBox ID="txtCompanyNameSearch" runat="server" Width="200px" CssClass="searchBox">
                            </asp:TextBox><asp:Label ID="lblWrongCompany" runat="server"></asp:Label>
                            <ajaxToolkit:AutoCompleteExtender ID="extCompanyNameSearch" runat="server" EnableCaching="true"
                                MinimumPrefixLength="1" OnClientPopulated="hide" OnClientPopulating="show" ServiceMethod="getCompanies"
                                ServicePath="AutoComplete.asmx" SkinID="AutoCompleteExtender" TargetControlID="txtCompanyNameSearch" />
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            Status
                        </td>
                        <td>
                            <asp:DropDownList ID="ddlStatus" runat="server" Enabled="false">
                                <asp:ListItem Value="All">All</asp:ListItem>
                                <asp:ListItem Value="Not Completed">Not completed</asp:ListItem>
                                <asp:ListItem Value="Completed">Completed</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Project
                        </td>
                        <td>
                            <asp:TextBox ID="txtProjectSearch" runat="server" Width="200px" CssClass="searchBox">
                            </asp:TextBox><asp:Label ID="lblWrongProject" runat="server"></asp:Label>
                            <ajaxToolkit:AutoCompleteExtender ID="extProjectSearch" runat="server" EnableCaching="true"
                                MinimumPrefixLength="1" OnClientPopulated="hide" OnClientPopulating="show" ServiceMethod="getProjects"
                                ServicePath="AutoComplete.asmx" SkinID="AutoCompleteExtender" TargetControlID="txtProjectSearch" />
                        </td>
                    </tr>
                    <tr id="trDates" runat="Server" visible="true">
                        <td style="width: 105px">
                            From Date
                        </td>
                        <td>
                            <clib:TextBoxCalendar ID="txtFromDate" runat="server" EnableViewState="true" ClearText=" ">
                            </clib:TextBoxCalendar>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            To Date
                        </td>
                        <td>
                            <clib:TextBoxCalendar ID="txtToDate" runat="server" EnableViewState="true" ClearText=" ">
                            </clib:TextBoxCalendar>
                        </td>
                        <td>
                            <asp:Button ID="btnSearch" runat="server" CausesValidation="False" OnClick="btnSearch_Click"
                                Text="Search &gt;&gt;" />
                        </td>
                    </tr>
                </table>

                <%--<script type="text/javascript" src="/browser_detect.js"></script>

                <script type="text/javascript" src="/popup.js"></script>--%>

                <script type="text/javascript">
                    function show(source, eventArgs) {
                        source.get_element().className = 'searchBoxSearching';
                    }
                    function hide(source, eventArgs) {
                        source.get_element().className = 'searchBox';
                    }
                </script>

            </asp:Panel>
            <br />
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" SkinID="GridView"
                AllowPaging="True" PageSize="15" AllowSorting="True" DataKeyNames="ID" OnPageIndexChanging="GridView1_PageIndexChanging"
                OnRowCommand="GridView1_RowCommand" OnRowDeleting="GridView1_RowDeleting">
                <Columns>
                    <asp:TemplateField HeaderText="" SortExpression="ID">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkID" runat="server" CausesValidation="false" CommandName="Select"
                                Text="Edit" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID"></asp:BoundField>
                    <asp:BoundField DataField="CompanyName" HeaderText="Company" SortExpression="CompanyName">
                    </asp:BoundField>
                    <asp:BoundField DataField="ProjectName" HeaderText="Project" SortExpression="ProjectName">
                    </asp:BoundField>
                    <asp:BoundField DataField="TaskName" HeaderText="Task" SortExpression="TaskName">
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Description">
                        <ItemTemplate>
                           <%-- <a onmouseover="poppup('<%# DataBinder.Eval(Container, "DataItem.Description") %>');" onmouseout="kill();"
                                title="" onfocus="this.blur();" href="" > Desc.
                            </a>--%>
                              <asp:LinkButton CommandName="Description" runat="server" ID="hypDescription" CausesValidation="false"
                                Text='<%# DataBinder.Eval(Container, "DataItem.DescriptionShort") %>' CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="CreationDate" HeaderText="Created" DataFormatString="{0:yyyy/MM/dd}"
                        HtmlEncode="false" SortExpression="CreationDate"></asp:BoundField>
                    <asp:BoundField DataField="Disabled" HeaderText="Disabled" SortExpression="Disabled">
                    </asp:BoundField>
                    <asp:BoundField DataField="EstimatedHours" HeaderText="Est.Hours" SortExpression="EstimatedHours">
                    </asp:BoundField>
                    <asp:BoundField DataField="StaffMemberAllocatedTo" HeaderText="Allocated To" SortExpression="StaffMemberAllocatedTo">
                    </asp:BoundField>
                    <asp:BoundField DataField="CompletionDate" HeaderText="Completed" DataFormatString="{0:yyyy/MM/dd}"
                        HtmlEncode="false" SortExpression="CompletionDate"></asp:BoundField>
                    <asp:BoundField DataField="Status" HeaderText="Project Status" SortExpression="Status"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="Begin" HeaderText="Project started" DataFormatString="{0:yyyy/MM/dd}"
                        HtmlEncode="false" SortExpression="Begin" Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="Category" HeaderText="Project Category" SortExpression="Category"
                        Visible="false"></asp:BoundField>
                    <asp:BoundField DataField="CustomerRefNumber" HeaderText="CustomerRefNumber" SortExpression="CustomerRefNumber">
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="URL">
                        <ItemTemplate>
                            <asp:HyperLink ID="HyperLink" runat="server" CausesValidation="false" Visible='<%# DataBinder.Eval(Container, "DataItem.URL") != DBNull.Value %>'
                                Text="Issue Log Details" NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.URL") %>'> 
                            </asp:HyperLink>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="">
                        <ItemTemplate>
                            <asp:LinkButton ID="AddTime" runat="server" CausesValidation="false" CommandName="Add"
                                Text="Add Time" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataTemplate>
                    No records found</EmptyDataTemplate>
                <PagerTemplate>
                    <table width="100%">
                        <tr>
                            <td style="text-align: left; font-size: 11px; width: 100px;">
                                Page
                                <asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                of
                                <asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount  %>' />
                            </td>
                            <td style="text-align: center; font-size: 11px;">
                                <asp:Panel ID="pnlPager" runat="server" DefaultButton="lnkGo">
                                    <asp:LinkButton ID="lnkFirst" runat="server" CausesValidation="False" CommandArgument="First"
                                        CommandName="Page" Text="Page 1" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
                                        CommandName="Page" Text="<< Prev" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkNext" runat="server" CausesValidation="False" CommandArgument="Next"
                                        CommandName="Page" Text="Next >>" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkLast" runat="server" CausesValidation="False" CommandArgument="Last"
                                        CommandName="Page" Text='<%# "Page "+ ((GridView)Container.Parent.Parent).PageCount  %>' />&nbsp;&nbsp;&nbsp;
                                    <asp:TextBox ID="txtNewPageIndex" runat="server" Width="20px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                    <asp:LinkButton ID="lnkGo" runat="server" CausesValidation="False" CommandArgument="-1"
                                        CommandName="Page" Text="Go" /><!-- here set the CommandArgument of the Go Button to '-1' as the flag -->
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </PagerTemplate>
            </asp:GridView>
        </ContentTemplate>
    </clib:UpdatePanelExtender>
</asp:Content>
